<template>
	<view>
		<view class="flex_c page" :style="'background-image: url(' + $c.config.media + 'yuemini/reg_bg.png);'">
			<view :style="{height:$store.state.StatusBar.statusBar + 'px'}">
			</view>
			<view class="flex_r fa_c nav">
				<view class="nav-icon" @click="to()">
					<image class="img" src="" mode="aspectFill"></image>
				</view>
	<!-- 			<view class="flex_r fa_c fj_c flex1 nav-list">
					<view class="flex_c_c color__ nav-list-item " :class="{nav_list_item: index === currentIndex}"
						v-for="(item,index) in navList" :key="index" @click="onNav(index)">
						<view class="nav-list-item-title">
							{{item.title}}
						</view>
						<view class="nav-str"></view>
					</view>
				</view> -->
				<view class="nav-icon">
				</view>
			</view>
			<!-- && isVip == false -->
			<view v-if="currentIndex == 0 && false" style="text-align: center;">
				<image style="width:360rpx; height:360rpx;" class="img" mode="aspectFill" src="./img/pic_no_focus_icon.png"></image>
				<view class="preview-list">
					<view class="proview-item" v-if="ix < 3" v-for="(im,ix) in list">
						<image class="img" mode="aspectFill" :src="im.gustpic"></image>
					</view>
					<view class="proview-item">
						<view style="width:100%; height:100%; background-color: #f00; color:#fff; font-size:35rpx; line-height: 80rpx;">+17</view>
					</view>
				</view>
				<view style="margin-top:120rpx; font-size:28rpx; color: #550000; color:#fff;">哇，有17个人默默关注我，对我感兴趣</view>
				<view style="margin-top:300rpx; font-size:28rpx; margin-bottom: 20rpx; color:#fff;">开通vip获取所有访客信息</view>
				<view class="button" @click="to('/pages/m-pages/m-vip/index')">开通vip</view>
			</view>
			<swiper v-else class="flex1 page-current" :current="currentIndex" @change="change">
				<swiper-item class="flex_c img" v-for="(item,index) in navList" :key="index">
					<scroll-view scroll-y class="flex1 scroll-v" refresher-enabled
						:refresher-triggered="item._refresherTriggered" @refresherrefresh="refresherrefresh(index)"
						@scrolltolower="scrolltolower(index)">
						<!-- <view class="flex_r fa_c item" v-for="(im,ix) in item.dataList"> -->
						<view class="flex_r fa_c item" v-for="(im,ix) in list">
							<view class="item-img">
								<image class="img" mode="aspectFill" :src="im.gustpic" v-if="currentIndex ==  0"></image>
								<image class="img" mode="aspectFill" :src="im.pic" v-else></image>
							</view>
							<view class="flex1 item-infr">
								<view class="flex_r fa_c  item-infr-top">
									<view class="text_32" style=" color:#fff;" v-if="currentIndex ==  0">
										{{im.gustname}}
									</view>
									<view class="text_32" style=" color:#fff;" v-else>
										{{im.nick}}
									</view>
						<!-- 			<view class="item-infr-top-img">
										<image class="img" src="./img/ic_boy.png" mode="aspectFill"></image>
										<image class="img" src="./img/ic_girl.png" mode="aspectFill"></image>
									</view> -->
						<!-- 			<view class="icon_ item-name-label">
										<image class="img" src="./img/ic_zhenren.png" mode="aspectFill"></image>
									</view> -->
								</view>
						<!-- 		<view class="color__ text_20" style="margin-top:10rpx;">
									<span v-if="im.user.age">{{im.user.address}}/</span>
									{{im.user.age}}
									<span v-if="im.user.shengao">/{{im.user.shengao}}</span>
									<span v-if="im.user.zhiyename">/{{im.user.zhiyename}}</span>
								</view> -->
								<view class="color__ text_20" style="margin-top:10rpx;">
									{{im.gusttime}}
								</view>
							</view>
							<!-- <view class="icon_ size_white text_26 item-button_"> -->
								<view class="flex_c_c item-r-icon" @click="goMsg(im)">
										<image class="img"  :src="$c.config.imageIP + 'yuemini/ic_home_dazhaohu.png'" mode="aspectFill"></image>
								</view>
								
							<!-- </view> -->
							
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	import {to} from '@/utils/index.js';
	export default {
		data() {
			return {
				$c: this.$c,
				currentIndex: 0,
				pageno: 1,
				list: [],
				isVip: false,
				heigh:50,
				navList: [{
						title: '谁看过我',
						type: 1,
						_refresherTriggered: false,
						loadingState: 'lom',
						startSize: 1,
						dataList: [],
						search: '' //搜索参数
					},
					{
						title: '我看过谁',
						type: 1,
						_refresherTriggered: false,
						loadingState: 'lom',
						startSize: 1,
						dataList: [],
						search: '' //搜索参数
					}
				]
			}
		},
		onLoad(option) {
			console.log(option)
			this.currentIndex = parseInt(option.currentIndex);
			this.pageno = 1;
			this.list = [];
			this.getList();
		},
		onShow(){
			// #ifdef APP-PLUS
			this.heigh = this.$store.state.StatusBar.statusBar; 
			// #endif
			// this.pageno = 1;
			// this.list = [];
			// this.getList();
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			to,
			onNav(index) {
				this.currentIndex = index
			},
			async getList(){
				let type = this.currentIndex ? 2 : 1;
				let res = await this.$c.post("/app/user/visitorLogPage?pageno="+this.pageno+"&type="+type)
				if(res.code != 0){
					
				}
				this.list = this.list.concat(res.data.list)
				console.log(res.data)
				this.isVip = res.data.isvip
				// this.isVip =false
				this.pageno++;
			},
			goMsg(item){
				
			  console.log(item.userid+'******'+item.user.tengxuncode);
			  uni.navigateTo({
				url: `/im/chat/chat?userid=`+item.userid+`&conversationID=C2C`+item.user.tengxuncode,
			  });
			},
			change(e) {
				this.currentIndex = e.detail.current
				this.pageno = 1;
				this.list = [];
				this.getList()
			},
			refresherrefresh(index) {
				console.log("下拉")
				const tabItem = this.navList[index]
				if (tabItem._refresherTriggered) {
					return;
				}
				tabItem._refresherTriggered = true
				tabItem.startSize = 1
				setTimeout(() => {
					tabItem._refresherTriggered = false
				}, 1000)
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {
		width: 100vw;
		height: 100vh;
		background: linear-gradient(#e3ecfb, #fdedf0, #fff, #fff);
	}

	.nav {
		box-sizing: border-box;
		padding: 0 30rpx;
		width: 100%;
		height: 100rpx;

		.nav-icon {
			width: 40rpx;
			height: 40rpx;
		}

		.nav-list {
			height: 100%;

			.nav-list-item {
				width: 150rpx;
				height: 100%;

				.nav-list-item-title {
					margin-bottom: 10rpx;
					transition: all .3s;
					color:#fff;
				}

				.nav-str {
					opacity: 0;
					width: 50rpx;
					height: 14rpx;
					border-radius: 7rpx;
					transition: all .3s;
				}
			}

			.nav_list_item {
				font-size: 34rpx;

				.nav-list-item-title {
					transition: all .3s;
					color: #e6166a;
				}

				.nav-str {
					opacity: 1;
					background-color: #e6166a;
				}
			}

		}
	}

	.page-current {
		position: relative;
		width: 100%;
		height: 0;

		.scroll-v {
			position: relative;
			box-sizing: border-box;
			width: 100%;
			height: 0;
		}
	}
	.preview-list{
		position: absolute;
		left:50%;
		transform: translateX(-50%);
		width:500rpx;
		height:90rpx;
		text-align:center;
		clear:both;
	}
	.proview-item{
		width:80rpx;
		height:80rpx;
		border-radius: 50%;
		overflow: hidden;
		float:left;
		margin: 20rpx;
	}
	.button{
		background-color: #ff5500;
		color:#fff;
		padding:10rpx 30rpx;
		height:60rpx;
		border-radius: 30rpx;
		font-size:34rpx;
		line-height: 60rpx;
		width:80%;
		margin: 0 auto;
		text-align: center;
	}


	.item {
		width: calc(100% - 60rpx);
		height: 160rpx;
		margin: 0 auto;

		.item-name-label {
			width: 100rpx;
			height: 40rpx;
			margin-left: 20rpx;
			border-radius: 20rpx;
		}
		
		.item-r-icon {
			width: 90rpx;
			height: 90rpx;
			border-radius: 50%;
			// background-color: #fff;
		}
		.item-img {
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			overflow: hidden;
			margin-right: 20rpx;
			background-color: #f1f1f1;
			
		}

		.item-infr {
			.item-infr-top {}

			.item-infr-top-img {
				width: 40rpx;
				height: 40rpx;
				overflow: hidden;
				border-radius: 50%;
				margin-left: 20rpx;
			}
		}

		.item-button {
			box-sizing: border-box;
			padding: 0 20rpx;
			height: 50rpx;
			text-align: center;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-color: #e8e1e8;
		}
		.item-button_{
			box-sizing: border-box;
			padding: 0 20rpx;
			height: 50rpx;
			text-align: center;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-image: linear-gradient(to right,rgba(230, 22, 106, 0.3),#e6166a);
			.item-button_icon{
				width: 30rpx;
				height: 30rpx;
				margin-right: 6rpx;
			}
		}
		
	}
</style>